package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout.LayoutParams;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.store.awk.bean.HorizontalCourseItemCardBean;
import com.huawei.appmarket.service.store.awk.bean.ThreeLineCourseCardBean;
import java.util.ArrayList;
import java.util.List;
import o.cgz;
import o.dof;

public class ThreeLineCourseCard extends BaseDistCard {
    private static int ʽ = 3;
    private static int ॱॱ = 1;
    private List<cgz> ʻ = new ArrayList();
    private View ʼ = null;
    ThreeLineCourseCardBean ˋ;
    private TitleCard ᐝ = null;

    public ThreeLineCourseCard(Context context) {
        super(context);
    }

    public TitleCard ˎ() {
        return this.ᐝ;
    }

    public void ˋ(TitleCard titleCard) {
        this.ᐝ = titleCard;
    }

    public void ˋ(View view) {
        this.ʼ = view;
    }

    public cgz ˋ(int i) {
        if (this.ʻ == null || i < 0 || i >= this.ʻ.size()) {
            return null;
        }
        return (cgz) this.ʻ.get(i);
    }

    public void ˋ(cgz o_cgz) {
        if (o_cgz != null) {
            this.ʻ.add(o_cgz);
        }
    }

    public int ˊ() {
        return this.ʻ.size();
    }

    public cgz ˏ(View view) {
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        int size;
        this.ˋ = (ThreeLineCourseCardBean) cardBean;
        if (this.ᐝ != null) {
            this.ᐝ.ˏ(this.ˋ);
            if (!ॱ(this.ˋ).booleanValue()) {
                this.ᐝ.ˎ().setVisibility(8);
                this.ᐝ.ˋ().setVisibility(8);
            }
        }
        if (this.ˋ.ॱ() != null) {
            size = this.ˋ.ॱ().size();
        } else {
            size = 0;
        }
        int i = 0;
        while (i < ˊ()) {
            CourseListCard courseListCard = (CourseListCard) ˋ(i);
            if (courseListCard != null) {
                if (i >= size) {
                    courseListCard.ˉ().setVisibility(8);
                } else {
                    courseListCard.ˉ().setVisibility(0);
                    CardBean cardBean2 = (HorizontalCourseItemCardBean) this.ˋ.ॱ().get(i);
                    cardBean2.ˋˋ(this.ˋ.ॱˉ());
                    if (i == ˊ() - 1 || i == size - 1) {
                        courseListCard.ॱ(true);
                    }
                    courseListCard.ˏ(cardBean2);
                    LayoutParams layoutParams = (LayoutParams) courseListCard.ˎ().getLayoutParams();
                    layoutParams.setMarginStart(0);
                    layoutParams.setMarginEnd(0);
                    if (courseListCard.ˊ()) {
                        courseListCard.ˋ().setVisibility(4);
                    } else {
                        courseListCard.ˋ().setVisibility(0);
                    }
                }
            }
            i++;
        }
        if (this.ʼ == null) {
            return;
        }
        if (this.ˋ.ॱㆍ()) {
            this.ʼ.setVisibility(8);
        } else {
            this.ʼ.setVisibility(0);
        }
    }

    private Boolean ॱ(ThreeLineCourseCardBean threeLineCourseCardBean) {
        boolean z = false;
        if (dof.ʽ(threeLineCourseCardBean.ॱॱ())) {
            return Boolean.valueOf(false);
        }
        if (threeLineCourseCardBean.ॱ().size() > ˊ()) {
            z = true;
        }
        return Boolean.valueOf(z);
    }

    public ArrayList<String> ˋ() {
        ArrayList<String> arrayList = new ArrayList();
        List ॱ = this.ˋ.ॱ();
        if (ॱ != null) {
            int i = ॱॱ;
            for (int i2 = 0; i2 < ʽ * i; i2++) {
                if (i2 < ॱ.size()) {
                    HorizontalCourseItemCardBean horizontalCourseItemCardBean = (HorizontalCourseItemCardBean) ॱ.get(i2);
                    arrayList.add(horizontalCourseItemCardBean.ॱॱ() + "#$#" + horizontalCourseItemCardBean.u_());
                }
            }
        }
        return arrayList;
    }
}
